extends Panel

func _ready():
	pass
func on_status_show(type,data_array):
	if $ScrollContainer/VBoxContainer.get_child_count() !=0:
		for children in $ScrollContainer/VBoxContainer.get_children():
			children.queue_free()
	match type:
		"game":
			$ListType.text = "我的游戏列表"
		"anime":
			$ListType.text = "我的动画列表"
		"book":
			$ListType.text = "我的书本列表"
		"film":
			$ListType.text = "我的电影列表"
		"tv":
			$ListType.text = "我的电视剧列表"
		"music":
			$ListType.text = "我的音乐列表"
	for key in data_array:
		var btn = Button.new()
		btn.set("custom_fonts/font",Global.font)
		btn.text = key
		$ScrollContainer/VBoxContainer.add_child(btn)
		btn.connect("pressed",get_tree().current_scene.get_node("StatusRecordPanel"),"on_edit_show",[type,btn.text])
	self.show()
func on_show(type):
	match type:
		"game":
			$ListType.text = "我的游戏列表"
			reflact_update_list(type)
		"anime":
			$ListType.text = "我的动画列表"
			reflact_update_list(type)
		"book":
			$ListType.text = "我的书本列表"
			reflact_update_list(type)
		"film":
			$ListType.text = "我的电影列表"
			reflact_update_list(type)
		"tv":
			$ListType.text = "我的电视剧列表"
			reflact_update_list(type)
		"music":
			$ListType.text = "我的音乐列表"
			reflact_update_list(type)
	
	
func reflact_update_list(type:String):
	if Global.dataJson.has(type):
		if $ScrollContainer/VBoxContainer.get_child_count() !=0:
			for children in $ScrollContainer/VBoxContainer.get_children():
				children.queue_free()
		for children in Global.dataJson[type]:
			var button = Button.new()
			button.text = children
			button.set("custom_fonts/font",Global.font)
			$ScrollContainer/VBoxContainer.add_child(button)
			button.connect("pressed",get_tree().current_scene.get_node("StatusRecordPanel"),"on_edit_show",[type,button.text])
		self.show()
	else:
		printerr("error no json key")
		get_tree().current_scene.get_node("ErrorPopup").popup()
func _on_Cancel_pressed():
	self.hide()
	pass # Replace with function body.
